package org.zkoss.zktc.core.groovy;

public class Snippet {

	String code;
	Status status = Status.NONE;
	
	String errMessage;
	Exception err;

	public Snippet(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Exception getErr() {
		return err;
	}

	public void setErr(Exception err) {
		this.err = err;
		setErrMessage(err.getMessage()==null?"":err.getMessage());
	}

	public String getErrMessage() {
		return errMessage;
	}

	public void setErrMessage(String errMessage) {
		this.errMessage = errMessage;
	}
	
	public boolean hasErr(){
		return err!=null || errMessage!=null;
	}
	
	public void clearErr(){
		errMessage = null;
		err = null;
	}
	
	public void clearStatus(){
		errMessage = null;
		err = null;
		status = Status.NONE;
	}
	
	public static enum Status {
	    NONE, FINE, ERROR 
	}
	
	
}
